package demo150;

public class intToRoman {
    public String intToRoman(int num) {
        String[] remon = new String[]{"M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"};
        int[] index= new        int[]{1000,900,500,400, 100,  90 ,50,40,  10,   9,  5, 4, 1};

        StringBuilder ret = new StringBuilder();
        for(int i = 0;i < remon.length;i++) {
            int tem = num/index[i];
            num = num % index[i];
            for(int j = 0;j<tem;j++) {
                ret.append(remon[i]);
            }
        }
        return ret.toString();
    }
}
